<template>
  <my-charts :id="chartId" :options="chartOption" width="100%" height="350px" />
</template>

<script>
import MyCharts from '@/components/MyCharts/index'
import { toolboxY } from '@/components/MyCharts/toolbox'

export default {
  name: 'BarChart',
  mixin: [],
  components: {
    'my-charts': MyCharts
  },
  props: {
    chartId: {
      type: String,
      default: 'bar-chart'
    },
    axisData: {
      type: Array,
      default: () => []
    },
    seriesData: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {}
  },
  computed: {
    chartOption: function() {
      const _series = this.seriesData.map(item => {
        return { name: item.name,
          type: 'bar',
          barWidth: '30%',
          data: item.data,
          markLine: {
            data: [
              { type: 'average' }
            ]
          }
        }
      })
      return {
        color: ['#3398DB'],
        toolbox: toolboxY('医院'),
        xAxis: [{ type: 'value' }],
        yAxis: [
          {
            type: 'category',
            data: this.axisData,
            axisTick: { alignWithLabel: true }
          }
        ],
        series: _series
      }
    }
  },
  watch: {},
  created() {
  },
  mounted() {
  },
  methods: {}
}
</script>

<style scoped lang="scss"></style>
